package com.vcredit.creditcat.web;

import com.vcredit.creditcat.model.ext.ProductConditionExt;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import com.vcredit.creditcat.model.ProductCondition;
import com.vcredit.creditcat.vo.ProductConditionVo;
import com.vcredit.creditcat.service.ProductConditionService;
import com.vcredit.creditcat.framework.pagination.Page;
 /*
  * @author zhangxingong
  * @version 1.0
  * @since 1.0
 */
@RestController
@RequestMapping("/productCondition")
public class ProductConditionController extends BaseController {
    
  @Autowired
  private ProductConditionService productConditionService;

  @RequestMapping(value = "/list", method = RequestMethod.GET)
  public ModelAndView  showPageProductCondition(HttpServletRequest request) {
      return new ModelAndView("/productcondition/productConditionList");
  }
	
	@RequestMapping(value = "/listProductCondition", method = RequestMethod.GET)
	public Page<ProductConditionExt> findByPageProductCondition(HttpServletRequest request) {
      return productConditionService.findByPage(makeDefaultCriteria(request));
	}
	
	@RequestMapping(value = "/saveProductCondition", method = RequestMethod.POST)
	public String saveProductCondition(@RequestBody ProductConditionVo productConditionVo,HttpServletRequest request) {
	    productConditionService.save(productConditionVo);
		return SUCCESS;
	}
	   
    @RequestMapping(value = "/updateProductCondition", method = RequestMethod.PUT)
    public String productConditionUpdate(@RequestBody ProductConditionVo productCondition,HttpServletRequest request) {
        productConditionService.update(productCondition);
        return SUCCESS;
    }
    
    @RequestMapping(value = "/removeProductCondition", method = RequestMethod.DELETE)
    public String removeProductCondition(@RequestParam("ids") String ids ,HttpServletRequest request) {
        productConditionService.removeProductCondition(ids);
        return SUCCESS;
    }	
}
